package com.practice.product.controller;

import com.practice.order.product.Product;
import com.practice.product.service.ProductService;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;


@RestController
//@RequestMapping("/api/product")
public class ProductController {

    @Autowired
    private ProductService productService;

    //查询商品
    @GetMapping("/product/{productId}")
    public Product getProduct(@PathVariable("productId") Long productId, HttpServletRequest  request){

        System.out.println("X - token 是 ...."+request.getHeader("X-Token"));

        Product product = productService.getByProductId(productId);

/*
        try {
            TimeUnit.SECONDS.sleep(2);
        } catch (InterruptedException e) {
            throw new RuntimeException();
        }
*/

        return product;

    }
}
